home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / glRenderWin.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  36.4 KB  |  1,485 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Description:
  22. //      Create the 'Hardware Render Buffer' window.
  23. //
  24. //    Contents
  25. //        resizeBufferRW()        Resize the render buffer and widow.
  26. //        setMenuStateRW()        Enable/disable size buttons.
  27. //        glResizePort()            Resize the render buffer and widow (user access).
  28. //        scaleBufMenuRW()        Callback for the pulldown scale menu.
  29. //        displayTimelineRW()        Set the visibility of the shelf tool.
  30. //        playbackRW()            Callback for the playback buttons.
  31. //        playbackScriptJobRW()    Script job for playback buttons.
  32. //        resChangedScriptJobRW()    Script job for resolution attribute changes.
  33. //        updateCameraMenuRW()    Update the camera pulldown menu.
  34. //
  35. //        flipbookRW()            Callback to setup for flipbook.
  36. //        updateFlipbookMenuRW()    Update the flipbook pulldown menu.
  37. //        clearFlipbookMenuRW()   Callback for the clear flipbook menu option.
  38. //        setFlipbookFlagsRW()    Callback for the set flipbook flags option.
  39. //        runFlipbookRW()            Callback for a flipbook menu item. 
  40. //        flipbookOptionMenuRW(); Build the Flipbook option menu.
  41. //        buildHardwareRenderBuffContextHelpItems() Creates context sensitive
  42. //                                menu items for the hardware render buffer.
  43. //
  44. //        createWinRW()            Create the window and all components..
  45. //        registerRW()            Register callbacks with the ui widgets.
  46. //        updateWinRW()            Update the window to match current render states.
  47. //        glRenderWin()            Main entry point.
  48. //
  49.  
  50.  
  51. global int        $glWinCameraCount     = 4;
  52. global int        $glRenderBufferWidth  = 646;
  53. global int        $glRenderBufferHeight = 485;
  54. global float    $glRenderBufferAspect = 1.33;
  55. global float    $glRenderBufferScale  = 1.0;
  56. global string    $glRenderBufferWin;
  57. global string    $glFlipbookOptions    = "";
  58.  
  59. // Global variables to store the menu items after the window is closed
  60. global string $glHWBufferItemCallbacks[];
  61. global string $glHWBufferItemLabels[];
  62.  
  63. // Must be sorted from high to low.
  64. global float $glHWrenderScales[] = {1., .7, .5, .3, .1};
  65.  
  66. global proc doGlRender()
  67. {
  68.     int $multipass = `getAttr defaultHardwareRenderGlobals.multiPassRendering`;
  69.     if ($multipass != 0) {
  70.         string $sl[] = `ls -sl`;
  71.         if (size($sl) > 0) {
  72.             warning("If Hardware Render does not stay on screen, you may need to clear your selection.");
  73.         }
  74.     }
  75.     glRender -renderFrame hardwareRenderView;
  76. }
  77.  
  78.  
  79. //  ========== isSizeOkayRW ==========
  80. //
  81. //  Description:
  82. //        Check if the given viewport dimensions make the
  83. //        window to big to fit on the screen.
  84. //
  85.  
  86. proc int  isSizeOkayRW( int $width, int $height, float $scale )
  87. {
  88.     int        $w = $scale * $width;
  89.     int        $h = $scale * $height;
  90.  
  91.     if (($w < 100) || ($w > 1100) || ($h < 100) || ($h > 825))
  92.         return 0;
  93.     return 1;
  94. }
  95.  
  96.  
  97.  
  98. //  ========== setMenuStateRW ==========
  99. //
  100. //  Description:
  101. //        Enable/disable the menu buttons as needed. This
  102. //        is to prevent the user from sizing the window
  103. //        too big or too small.
  104. //
  105.  
  106. proc  setMenuStateRW()
  107. {
  108.     global int        $glRenderBufferWidth;
  109.     global int        $glRenderBufferHeight;
  110.     global float    $glHWrenderScales[];
  111.  
  112.     int    $state;
  113.  
  114.     setParent glRenderWindow;
  115.  
  116.     for ($i = 0; $i < size($glHWrenderScales) ; $i++)
  117.     {
  118.         $state = isSizeOkayRW($glRenderBufferWidth, $glRenderBufferHeight, 
  119.                               $glHWrenderScales[$i]);
  120.         menuItem -e -enable $state ("scaleItem"+$i);
  121.     }
  122. }
  123.  
  124.  
  125.  
  126. //  ========== findGoodSizeRW ==========
  127. //
  128. //  Description:
  129. //        Find a good window size for the current buffer selection.
  130. //        If the current scale is okay, then use it, otherwise
  131. //        find the largest scale that is valid.
  132. //
  133.  
  134. proc  findGoodSizeRW()
  135. {
  136.     global int        $glRenderBufferWidth;
  137.     global int        $glRenderBufferHeight;
  138.     global float    $glRenderBufferScale;
  139.     global float    $glHWrenderScales[];
  140.     
  141.     setParent glRenderWindow;
  142.  
  143.     if (isSizeOkayRW($glRenderBufferWidth, $glRenderBufferHeight,
  144.                      $glRenderBufferScale ))
  145.     {
  146.         return;
  147.     }
  148.  
  149.     for ($i = 0; $i < size($glHWrenderScales) ; $i++)
  150.     {
  151.         if (isSizeOkayRW($glRenderBufferWidth, $glRenderBufferHeight, 
  152.                          $glHWrenderScales[$i]))
  153.         {
  154.             $glRenderBufferScale = $glHWrenderScales[$i];
  155.             menuItem -e -rb true -enable true ("scaleItem"+$i);
  156.             break;
  157.         }
  158.     }
  159.  
  160.     // Now enable/disable the menu buttons for the valid sizes.
  161.     //
  162.     setMenuStateRW();
  163. }
  164.  
  165.  
  166.  
  167. //  ========== resizeBufferRW ==========
  168. //
  169. //  Description:
  170. //        Resize the render buffer and window. The size is 
  171. //        read from global variables.
  172. //
  173.  
  174. global proc  resizeBufferRW( float $scale )
  175. {
  176.     // Check if new scale set. 
  177.     //
  178.     if ($scale > 0.0)
  179.     {
  180.         global float    $glRenderBufferScale;
  181.  
  182.         $glRenderBufferScale = $scale;
  183.     }
  184.     else
  185.     {
  186.         // Make sure the window is a good size. If the window is
  187.         // too big, or too small, resize it. Then dim the menu
  188.         // items that would create bad window sizes. 
  189.         //
  190.         findGoodSizeRW();
  191.     }
  192.  
  193.  
  194.     // Render layout minimum size.
  195.     //
  196.     int        $minWidth  = 323;
  197.     int        $minHeight = 200;
  198.  
  199.  
  200.     // Set view pane to image size. 
  201.     global int        $glRenderBufferWidth;
  202.     global int        $glRenderBufferHeight;
  203.     global float    $glRenderBufferAspect;
  204.     global float    $glRenderBufferScale;
  205.  
  206.  
  207.     //
  208.     // GG: need to add 4 to each side for frameLayout border.
  209.     //
  210.     int        $margin = 4;
  211.     int        $fudgeW = $margin;
  212.     int        $fudgeH = $margin;
  213.  
  214.     if (!`about -nt` && !`about -mac`)
  215.     {
  216.         // The (Motif) ui seems to need a fudge
  217.         // factor of 4 in order to get the correct viewport size.
  218.         //
  219.  
  220.         $fudgeW = $fudgeW + 2;
  221.         $fudgeH = $fudgeH - 4;
  222.     } else if ( `about -mac` ) {
  223.         // The mac ui does not need a  fudge factor
  224.         //
  225.         $fudgeH = 0;
  226.     }
  227.  
  228.  
  229.     // Set the image output resolution in the hardware render manager.
  230.     //
  231.     glRender -e -imageSize $glRenderBufferWidth $glRenderBufferHeight $glRenderBufferAspect;
  232.  
  233.  
  234.     // Set the viewport size for rendering.
  235.     //
  236.     int  $imageWidth  = $glRenderBufferScale * $glRenderBufferWidth + 0.5;
  237.     int  $imageHeight = $glRenderBufferScale * $glRenderBufferHeight + 0.5;
  238.  
  239.     glRender -e -viewport $imageWidth $imageHeight $glRenderBufferAspect;
  240.  
  241.  
  242.     // Now make the window a little bigger to accomodate errors
  243.     // in the elf widget hierarchy.
  244.     //
  245.     int  $frameWidth  = $imageWidth + $fudgeW;
  246.     int  $frameHeight = $imageHeight + $fudgeH;
  247.  
  248.     // Make sure window does not get too small.
  249.     //
  250.     int  $marginWidth  = 4;
  251.     int  $marginHeight = 4;
  252.  
  253.     if (($frameWidth + (2 * $marginWidth)) < $minWidth)
  254.     {
  255.         $marginWidth = (($minWidth - $frameWidth) / 2.0) + 0.5;
  256.     }
  257.  
  258.     if (($frameHeight + (2 * $marginHeight)) < $minHeight)
  259.     {
  260.         $marginHeight = (($minHeight - $frameHeight) / 2.0) + 0.5;
  261.     }
  262.  
  263.  
  264.     // Set view panel to the new image size.
  265.     //
  266.     if( `about -mac`)
  267.     {
  268.         setParent ("glRenderWindow"+"|renderBufferForm"+"|glRenderMenLayout"+"|workLyt");
  269.     }
  270.     else {
  271.         setParent glRenderWindow;
  272.     }
  273.  
  274.     formLayout -e
  275.         -af viewFrame left $marginWidth
  276.         -af viewFrame top  $marginHeight
  277.         -af viewFrame right $marginWidth
  278.         -af viewFrame bottom $marginHeight
  279.         viewLyt;
  280.  
  281.  
  282.     // I now need to set both the width and
  283.     // height on the window directly. (12/17/96)
  284.     //
  285.     int        $width = $frameWidth + (2 * $marginWidth);
  286.     int        $height = $frameHeight + 30 + (2 * $marginHeight);
  287.  
  288.     if (`menuItem -q -checkBox timelineItem`)
  289.     {
  290.         int    $x = `formLayout -q -height timeLineLyt`;
  291.  
  292.         $height = $height + `formLayout -q -height timeLineLyt`;
  293.     }
  294.  
  295.     if (`about -nt`)
  296.     {
  297.         //
  298.         // GG: Irix sizes assumming a 30 pixel high
  299.         // title bar. On NT, there is no fixed title bar height, instead
  300.         // we can set the size of the top-level layout, but we need
  301.         // to subtract the 30 pixels added for irix.
  302.         // also, since a window will only "grow" in size, we first size
  303.         // the window to its smallest size.
  304.         //
  305.         window -e -widthHeight 1 1 glRenderWindow;
  306.         control -e -width $width -height ($height-30) ("glRenderWindow"+"|workLyt");
  307.     }
  308.     else
  309.     {
  310.         if (`about -mac`)
  311.         {
  312.             //window -e -widthHeight $width $height ("glRenderWindow");
  313.             //control -e -width $width -height $height ("glRenderWindow"+"|renderBufferForm"+ "|glRenderMenLayout" + "|workLyt");
  314.             //We need to add the size of the menubar
  315.             window -e -widthHeight $width ($height+12) glRenderWindow;
  316.         }
  317.         else
  318.             window -e -widthHeight $width $height glRenderWindow;
  319.     }
  320.  
  321.     // Enable/disable the menu buttons for the
  322.     // current buffer size.
  323.     //
  324.     setMenuStateRW();
  325.  
  326.  
  327. }  // resizeBufferRW //
  328.  
  329.  
  330.  
  331. //  ========== glResizePort ==========
  332. //
  333. //  Description:
  334. //        Resize the render buffer and window. This is a hidden
  335. //        access method to resize the render port to an arbitrary
  336. //        size.
  337. //
  338.  
  339. global proc  glResizePort( int $width, int $height )
  340. {
  341.     global int        $glRenderBufferWidth;
  342.     global int        $glRenderBufferHeight;
  343.  
  344.     $glRenderBufferWidth = $width;
  345.     $glRenderBufferHeight = $height;
  346.  
  347.     resizeBufferRW( 0.0 );
  348. }
  349.  
  350.  
  351. //  ========== scaleBufMenuRW ==========
  352. //
  353. //  Description:
  354. //        Callback for the buffer scale pulldown menu.
  355. //        Also sets the scale option menu.
  356. //
  357.  
  358. global proc scaleBufMenuRW( string $win, int $scale )
  359. {
  360.     global float    $glHWrenderScales[];
  361.  
  362.     setParent $win;
  363.     resizeBufferRW($glHWrenderScales[$scale]);
  364. }
  365.  
  366. global proc flipbookOptionMenuRW()
  367. {
  368.     global string $glRenderBufferWin;
  369.     setParent $glRenderBufferWin;
  370.  
  371.     if(`about -mac`)
  372.     {
  373.         menuItem -p flipbookMenu
  374.             -l "Clear Flipbook Menu" 
  375.             -c "clearFlipbookMenuRW"
  376.             clearFlipbookItem;
  377.     }else{
  378.         menuItem -p flipbookMenu
  379.         -l "Options" 
  380.         -subMenu true 
  381.         flipbookOptionsItem;
  382.  
  383.         menuItem -l "Clear Flipbook Menu" 
  384.             -c "clearFlipbookMenuRW"
  385.             clearFlipbookItem;
  386.  
  387.         menuItem -l "Flipbook Flags..."
  388.             -c "setFlipbookFlagsRW"
  389.             flipbookFlagsItem;
  390.  
  391.         setParent -menu ..;
  392.     }
  393. }
  394.  
  395. global proc updateFlipbookMenuRW(string $label, string $cbArgList)
  396. {
  397.     global string $glRenderBufferWin;
  398.     global string $glHWBufferItemCallbacks[];
  399.     global string $glHWBufferItemLabels[];
  400.     setParent $glRenderBufferWin;
  401.     
  402.     int $i, $j;
  403.     int $numCurrFlipbooks = size($glHWBufferItemLabels);
  404.     for ($i = 0 ; $i<$numCurrFlipbooks ; $i++ )
  405.     {
  406.         // If the item is already there, just move it up
  407.         if ($label == $glHWBufferItemLabels[$i])
  408.             break;
  409.     }
  410.  
  411.     // Item was not found, make some room
  412.     if ($i >= $numCurrFlipbooks)
  413.     {
  414.         $numCurrFlipbooks++;
  415.         if ($numCurrFlipbooks > 10) $numCurrFlipbooks = 10;    
  416.         print ("FlipBooks: "+$numCurrFlipbooks+"\n");
  417.     }
  418.     else
  419.         $numCurrFlipbooks = $i+1;
  420.         
  421.     // Move all the items by one slot, to free up one space
  422.     for ($i = $numCurrFlipbooks-1 ; $i > 0 ; $i-- )
  423.     {
  424.         $glHWBufferItemCallbacks[$i] = $glHWBufferItemCallbacks[$i-1];
  425.         $glHWBufferItemLabels[$i]    = $glHWBufferItemLabels[$i-1];
  426.     }
  427.  
  428.     // Add the new item
  429.     $glHWBufferItemLabels[0] = $label;
  430.     $glHWBufferItemCallbacks[0] = ("runFlipbookRW " + $cbArgList);
  431.  
  432.     // Delete the old menu and rebuild, with the new item on top.
  433.     menu -e -dai flipbookMenu;
  434.  
  435.     for ($i = 0 ; $i < $numCurrFlipbooks ; $i++)
  436.         menuItem -p flipbookMenu 
  437.             -l $glHWBufferItemLabels[$i] -c $glHWBufferItemCallbacks[$i];
  438.  
  439.     flipbookOptionMenuRW();
  440. }
  441.  
  442. //  ========== flipbookRW ==========
  443. //
  444. //  Description:
  445. //        Called when the user has competed a render sequence.  Set up
  446. //        to allow the user to run fcheck to see the sequence.
  447. //
  448.  
  449. global proc  flipbookRW( string $image, 
  450.                          int $fs, int $fe, int $fi, int $rate, 
  451.                          string $path, string $filename )
  452. {
  453.     // Build a label for the pulldown menu item.  It will be the
  454.     // <imageName>.<startFrame>-<endFrame>
  455.     // 
  456.     string $label = $image + "." + $fs + "-" + $fe;
  457.     string $fullName = $path;
  458.     if (substring($path, size($path), size($path)) != "/")
  459.         $fullName = $fullName + "/";
  460.  
  461.     $fullName = "\"" + $fullName + $filename + "\"";
  462.     string $rateString;
  463.     switch ($rate)
  464.     {
  465.         case 24: $rateString = "film ";
  466.                  break;
  467.         case 30: $rateString = "ntsc ";
  468.                  break;
  469.         case 25: $rateString = "pal";
  470.                  break;
  471.         default:
  472.                 $rateString = "none";
  473.                 break;
  474.     }
  475.  
  476.     string $argList = $fs + " " + $fe + " " + $fi + " " + $rateString + " ";
  477.     $argList = $argList + $fullName;
  478.  
  479.     updateFlipbookMenuRW($label, $argList);
  480. }
  481.  
  482.  
  483. //  ========== clearFlipbookMenuRW ==========
  484. //
  485. //  Description:
  486. //        Callback for Flipbook->Options->Clear Flipbook Menu.
  487. //        Clear the menu, then remake the options menu items. 
  488. //
  489.  
  490. global proc clearFlipbookMenuRW()
  491. {
  492.     global string $glHWBufferItemCallbacks[];
  493.     global string $glHWBufferItemLabels[];
  494.  
  495.     menu -e -dai flipbookMenu;
  496.     clear $glHWBufferItemCallbacks;
  497.     clear $glHWBufferItemLabels;
  498.  
  499.     flipbookOptionMenuRW();
  500. }
  501.  
  502.  
  503.  
  504. //  ========== FFokBtnRW ==========
  505. //
  506. //  Description:
  507. //        This is the callback for the OK button in the 
  508. //        flipbook options dialog. It saves the new flags
  509. //        in the global flags variable.
  510. //
  511.  
  512. global proc FFokBtnRW( string $win )
  513. {
  514.     global string    $glFlipbookOptions;
  515.  
  516.     setParent $win;
  517.     $glFlipbookOptions = `textField -q -text flipbookFlagsTF`;
  518.     window -e -vis 0 $win;
  519. }
  520.  
  521.  
  522.  
  523. //  ========== FFcancelBtnRW ==========
  524. //
  525. //  Description:
  526. //        This is the callback for the Cancel button in the 
  527. //        flipbook options dialog. It restores the fcheck flags
  528. //        into the textfield.
  529. //
  530.  
  531. global proc FFcancelBtnRW( string $win )
  532. {
  533.     global string    $glFlipbookOptions;
  534.  
  535.     setParent $win;
  536.     textField -e -text $glFlipbookOptions flipbookFlagsTF;
  537.     window -e -vis 0 $win;
  538. }
  539.  
  540.  
  541.  
  542. //  ========== setFlipbookFlagsRW ==========
  543. //
  544. //  Description:
  545. //        This is the callback for Flipbook->Options->Flipbook Flags .
  546. //        It brings up a dialog for the user to set additional flags.
  547. //
  548.  
  549. global proc setFlipbookFlagsRW()
  550. {
  551.     if (!`window -exists flipbookFlagsWin`)
  552.     {
  553.         window
  554.             -title "Flipbook Options"
  555.             -retain 
  556.             -widthHeight 420 130
  557.             -interactivePlacement
  558.             flipbookFlagsWin;
  559.  
  560.         frameLayout 
  561.             -borderVisible false 
  562.             -collapsable false 
  563.             -labelVisible false 
  564.             -marginHeight 2
  565.             flipbookFlagsFL;
  566.  
  567.         formLayout 
  568.             -numberOfDivisions 100 
  569.             flipBookFlagsF;
  570.  
  571.         text 
  572.             -label "Set any options for fcheck except \"-n\" and \"-r\", which are"
  573.             -align "left"
  574.             text1RW; 
  575.  
  576.         text 
  577.             -label "set to the frame range, increment and rate you rendered with."
  578.             -align "left"
  579.             text2RW;
  580.  
  581.         text 
  582.             -label "Options:"
  583.             -align "left"
  584.             optionsTextRW;
  585.  
  586.         textField
  587.             -width 280
  588.             -text ""
  589.             flipbookFlagsTF;
  590.  
  591.         button
  592.             -label "OK"
  593.             -height 26
  594.             -command "FFokBtnRW flipbookFlagsWin"
  595.             flipbookFlagsOKBtn;
  596.  
  597.         button
  598.             -label "Cancel"
  599.             -height 26
  600.             -command "FFcancelBtnRW flipbookFlagsWin"
  601.             flipbookFlagsCancelBtn;
  602.  
  603.         formLayout -e
  604.             -af text1RW top 0
  605.             -af text1RW left 20  
  606.             -ac text2RW top 0 text1RW
  607.             -af text2RW left 20
  608.             -ac optionsTextRW top 10 text2RW
  609.             -af optionsTextRW left 20
  610.             -ac flipbookFlagsTF top 8 text2RW
  611.             -ac flipbookFlagsTF left 4 optionsTextRW
  612.             -af flipbookFlagsTF right 20
  613.             -af flipbookFlagsOKBtn left 10
  614.             -ap flipbookFlagsOKBtn right 5 50
  615.             -af flipbookFlagsOKBtn bottom 10
  616.             -af flipbookFlagsCancelBtn right 10
  617.             -ap flipbookFlagsCancelBtn left 5 50
  618.             -af flipbookFlagsCancelBtn bottom 10
  619.             flipBookFlagsF;
  620.     }
  621.  
  622.     showWindow flipbookFlagsWin;
  623. }
  624.  
  625.  
  626. //  ========== runFlipbookRW ==========
  627. //
  628. //  Description:
  629. //        This is the callback for the Flipbook menu items.
  630. //        It will execute fcheck with the arguments supplied.
  631. //
  632.  
  633. global proc runFlipbookRW( int $fs, int $fe, int $fi,
  634.                             string $rate,
  635.                             string $filename)
  636. {
  637.     global string    $glFlipbookOptions = "";
  638.  
  639.     string $cmd;
  640.         $cmd = "fcheck ";
  641.     if(`about -mac`) {
  642.         $cmd = $cmd + "-r " + $rate;
  643.         $cmd = $cmd + " -n " + $fs  + " " + $fe + " " + $fi;
  644.        }
  645.     else {
  646.         $cmd = $cmd + "-n " + $fs  + " " + $fe + " " + $fi;
  647.         $cmd = $cmd + " -r " + $rate;
  648.     }
  649.  
  650.     if (size($glFlipbookOptions) > 0)
  651.         $cmd = $cmd + " " + $glFlipbookOptions + " ";
  652.     $cmd = $cmd + " \"" + $filename + "\"";
  653.  
  654.     print( "// Result: "+$cmd+"\n" );
  655.  
  656.     if (`about -nt` || `about -mac`)
  657.     {
  658.         eval ($cmd);
  659.     } else {
  660.         system($cmd+">/dev/null 2>&1");  // GG: Irix Only
  661.     }
  662. }
  663.  
  664.  
  665. //  ========== displayTimelineRW ==========
  666. //
  667. //  SYNOPSIS
  668. //        Toggle the display of the timeline tool.
  669. //
  670.  
  671. global proc displayTimelineRW( string $win, int $visible )
  672. {
  673.  
  674.     if ($visible)
  675.     {
  676.         formLayout -e -vis true ($win+"|workLyt|timeLineLyt");
  677.         setParent ($win+"|workLyt");
  678.         formLayout -e -ac viewLyt bottom 0 timeLineLyt ($win+"|workLyt");
  679.     }
  680.     else
  681.     {
  682.         formLayout -e -vis false ($win+"|workLyt|timeLineLyt");
  683.         setParent ($win+"|workLyt");
  684.         formLayout -e -af viewLyt bottom 0 ($win+"|workLyt");
  685.     }
  686.  
  687.  
  688.     // Force the window to resize correctly.
  689.     //
  690.     resizeBufferRW( 0.0 );
  691. }
  692.  
  693. //  ========== playbackRW ==========
  694. //
  695. //  Description:
  696. //        Callback for the playback buttons. Controls playing forward,
  697. //        backward, etc. Mimic the same behavior as the timeSlider
  698. //        buttons in the main window.
  699. //
  700.  
  701. global proc  playbackRW( string $win, int $mode )
  702. {
  703.     setParent $win;
  704.  
  705.     switch ($mode)
  706.     {
  707.         case 1 :    // Rewind
  708.         {
  709.             currentTime -edit `playbackOptions -query -min`;
  710.         } break;
  711.         
  712.  
  713.         case 2 :    // Step backward
  714.         {
  715.             float    $by   = `playbackOptions -query -by`;
  716.             float    $curr = `currentTime -query`;
  717.             float    $min  = `playbackOptions -query -min`;
  718.  
  719.             if (($curr - $by) >= $min)
  720.             {
  721.                 currentTime -edit ($curr - $by);
  722.             }
  723.         } break;
  724.  
  725.  
  726.         case 3 :    // Play backward
  727.         {
  728.             if ((`play -query -state` == 1) && (`play -query -forward` == 0))
  729.             {
  730.                 // Stop playback. Let the script job reset the button images.
  731.                 //
  732.                 play -state off;
  733.             }
  734.             else
  735.             {
  736.                 if (`currentTime -q` <= `playbackOptions -q -min`)
  737.                 {
  738.                     currentTime -e `playbackOptions -q -max`;
  739.                 }
  740.  
  741.                 symbolButton -edit -image "timestop.xpm" 
  742.                     -ann "Stop playback" playBwdBtn;
  743.  
  744.                 if (`symbolButton -q -i playFwdBtn` != "timeplay.xpm")
  745.                 {
  746.                     symbolButton -edit -image "timeplay.xpm"
  747.                         -ann "Play forward" playFwdBtn;
  748.                 }
  749.  
  750.                 play -forward off;
  751.             }
  752.         } break;
  753.  
  754.  
  755.         case 4 :    // Play forward
  756.         {
  757.             if ((`play -query -state` == 1) && (`play -query -forward` == 1))
  758.             {
  759.                 // Stop playback. Let the script job reset the button images.
  760.                 //
  761.                 play -state off;
  762.             }
  763.             else
  764.             {
  765.                 if (`currentTime -q` >= `playbackOptions -q -max`)
  766.                 {
  767.                     currentTime -e `playbackOptions -q -min`;
  768.                 }
  769.  
  770.                 symbolButton -edit -image "timestop.xpm" 
  771.                     -ann "Stop playback" playFwdBtn;
  772.  
  773.                 if (`symbolButton -q -i playBwdBtn` != "timerev.xpm")
  774.                 {
  775.                     symbolButton -edit -image "timerev.xpm" 
  776.                         -ann "Play backwards" playBwdBtn;
  777.                 }
  778.  
  779.                 play -forward on;
  780.             }
  781.         } break;
  782.  
  783.  
  784.         case 5 :
  785.         {
  786.             float    $by   = `playbackOptions -query -by`;
  787.             float    $curr = `currentTime -query`;
  788.             float    $max  = `playbackOptions -query -max`;
  789.  
  790.             if (($curr + $by) <= $max)
  791.             {
  792.                 currentTime -edit ($curr + $by);
  793.             }
  794.         } break;
  795.  
  796.  
  797.         case 6 :
  798.         {
  799.             currentTime -edit `playbackOptions -query -max`;
  800.         } break;
  801.     }
  802. }  // playbackRW //
  803.  
  804.  
  805.  
  806. //  ========== playbackScriptJobRW ==========
  807. //
  808. //  Description:
  809. //        Make sure that the buttons are in sync with the current
  810. //        playback mode. This script job gets called whenever the
  811. //        playback state changes. BUG: this script actually only
  812. //        gets called when playback stops.
  813. //
  814.  
  815. global proc  playbackScriptJobRW( string $win )
  816. {
  817.     if (!`window -q -visible $win`) return;
  818.  
  819.     if (`play -query -state` == 0)
  820.     {
  821.         setParent $win;
  822.  
  823.         if (`symbolButton -q -i playBwdBtn` != "timerev.xpm")
  824.         {
  825.             symbolButton -edit -image "timerev.xpm" 
  826.                 -ann "Play backwards" playBwdBtn;
  827.         }
  828.  
  829.         if (`symbolButton -q -i playFwdBtn` != "timeplay.xpm")
  830.         {
  831.             symbolButton -edit -image "timeplay.xpm" 
  832.                 -ann "Play forward" playFwdBtn;
  833.         }
  834.     }
  835. }  // playbackScriptJobRW //
  836.  
  837.  
  838.  
  839. //  ========== resChangedScriptJobRW ==========
  840. //
  841. //  Description
  842. //        This proc gets called whenever the resolution attribute
  843. //        on the hwRenderGlobals node changes. This proc is
  844. //        used to resize the hardware render window to make sure
  845. //        its in sync with the attribute value.
  846. //
  847.  
  848. global proc  resChangedScriptJobRW( string $win )
  849. {
  850.     // Get the name of the hardware render globals node.
  851.     //
  852.     string  $hwNodes[] = `ls -type hwRenderGlobals`;
  853.     if (size( $hwNodes ) == 0) return;
  854.  
  855.  
  856.     // Get the new resolution values.
  857.     //
  858.     string    $hwRes = `getAttr ($hwNodes[0]+".resolution")`;
  859.     string  $tokenAry[];
  860.     int        $width, $height;
  861.     float    $aspect;
  862.  
  863.     tokenize( $hwRes, " ", $tokenAry );
  864.     $width = $tokenAry[1];
  865.     $height = $tokenAry[2];
  866.     $aspect = $tokenAry[3];
  867.  
  868.  
  869.     // Store the new values in the global variables for the
  870.     // scripts to use. Then call the resize proc.
  871.     //
  872.     global int        $glRenderBufferWidth;
  873.     global int        $glRenderBufferHeight;
  874.     global float    $glRenderBufferAspect;
  875.  
  876.     $glRenderBufferWidth = $width;
  877.     $glRenderBufferHeight = $height;
  878.     $glRenderBufferAspect = $aspect;
  879.  
  880.     resizeBufferRW( 0.0 );
  881. }  // resChangedScriptJobRW //
  882.  
  883.  
  884.  
  885. //  ========== updateCameraMenuRW ==========
  886. //
  887. //  Description:
  888. //        Update the camera pulldown menu. Use the camera shape
  889. //        name as the label.
  890. //
  891.  
  892. global proc  updateCameraMenuRW( string $win )
  893. {
  894.     setParent $win;
  895.  
  896.     // Get the current list of cameras in the scene. The ls command
  897.     // returns shape names. Prune this list to return the parent
  898.     // transform name.
  899.     //
  900.     string    $cameraShapeAry[] = `ls -cameras`;
  901.     int        $cameraShapeCnt = size( $cameraShapeAry );
  902.     string    $cameraNameAry[] = `ls -long -cameras`;
  903.     int        $cameraNameCnt = $cameraShapeCnt;
  904.  
  905.     for ($i = 0; $i < $cameraNameCnt; $i++)
  906.     {
  907.         string    $words[];
  908.  
  909.         tokenize( $cameraNameAry[$i], "|", $words );
  910.         $cameraNameAry[$i] = $words[size( $words ) - 2];
  911.     }
  912.  
  913.  
  914.     // Rebuild the camera pulldown menu as needed to match
  915.     // the current list of available cameras.
  916.     //
  917.     global int    $glWinCameraCount;
  918.     $glWinCameraCount = `menu -q -ni cameraMenu`;
  919.     int            $i, $loopCnt, $doCase;
  920.     int            $camCnt = $cameraNameCnt;
  921.     string        $activeCamera = `glRenderEditor -q -vcn hardwareRenderView`;
  922.  
  923.  
  924.     if ($glWinCameraCount == $camCnt)
  925.     {
  926.         $loopCnt = $glWinCameraCount;
  927.         $doCase = 0;
  928.     }
  929.     else if ($glWinCameraCount < $camCnt)
  930.     {
  931.         $loopCnt = $glWinCameraCount;
  932.         $doCase = 1;
  933.     }
  934.     else
  935.     {
  936.         $loopCnt = $camCnt;
  937.         $doCase = 2;
  938.     }
  939.  
  940.     // Update existing button labels and callback actions.
  941.     //
  942.     for ($i = 0; $i < $loopCnt; $i++)
  943.     {
  944.         string    $btnName = "glCameraItem"+$i;
  945.         string    $btnLbl = `menuItem -q -l $btnName`;
  946.  
  947.         if ($btnLbl != $cameraNameAry[$i])
  948.         {
  949.             menuItem -e 
  950.                 -l $cameraNameAry[$i]
  951.                 -cl glCameraCluster
  952.                 -c ("glRenderEditor -e -lookThru "+$cameraShapeAry[$i]+" hardwareRenderView")
  953.                 $btnName;
  954.         }
  955.  
  956.         menuItem -e -rb ($activeCamera == $cameraShapeAry[$i] ? true : false) $btnName;
  957.     }
  958.  
  959.  
  960.     // Add buttons to camera menu for new cameras.
  961.     //
  962.     if ($doCase == 1)
  963.     {
  964.         for ($i = $loopCnt; $i < $camCnt; $i++)
  965.         {
  966.             global int    $glWinCameraCount;
  967.             string        $btnName = "glCameraItem"+$glWinCameraCount;
  968.  
  969.             $glWinCameraCount++;
  970.  
  971.             menuItem 
  972.                 -p cameraMenu 
  973.                 -l $cameraNameAry[$i] 
  974.                 -rb ($activeCamera == $cameraShapeAry[$i] ? true : false)
  975.                 -cl glCameraCluster
  976.                 -c ("glRenderEditor -e -lookThru "+$cameraShapeAry[$i]+" hardwareRenderView")
  977.                 $btnName;
  978.         }
  979.     }
  980.  
  981.  
  982.     // Delete extra buttons from camera menu.
  983.     //
  984.     if ($doCase == 2)
  985.     {
  986.         setParent -menu cameraMenu;
  987.  
  988.         for ($i = $glWinCameraCount; $i > $loopCnt; $i--)
  989.         {
  990.             global int    $glWinCameraCount;
  991.             $glWinCameraCount--;
  992.             string    $btnName = "glCameraItem"+$glWinCameraCount;
  993.             deleteUI -menuItem $btnName;
  994.         }
  995.     }
  996. }  // updateCameraMenuRW //
  997.  
  998. //  ========== buildHardfwareRenderBuffContextHelpItems ===========
  999. //
  1000. //  SYNOPSIS
  1001. //        Build context sensitive menu items for the  
  1002. //        hardware render buffer window.  
  1003. //        
  1004. //  Input Arguments:
  1005. //        $nameRoot - name to use as the root of all item names
  1006. //        $menuParent - the name of the parent of this menu
  1007. //
  1008. global proc buildHardwareRenderBuffContextHelpItems(string $nameRoot, string $menuParent)
  1009. {
  1010.     menuItem -label "Help on Hardware Render Buffer..."
  1011.         -enableCommandRepeat false
  1012.         -command "showHelp HardwareRenderBuffer";
  1013. }
  1014.  
  1015. //  ========== createMenuRW ==========
  1016. //
  1017. //  SYNOPSIS
  1018. //        Create the menu and all the menu items.
  1019. //
  1020.  
  1021. proc  createMenuRW( string $parent )
  1022. {    
  1023.     global string $glHWBufferItemCallbacks[];
  1024.     global string $glHWBufferItemLabels[];
  1025.     global float  $glHWrenderScales[];        
  1026.     // Create the menubar.
  1027.     //
  1028.     menu -p $parent 
  1029.         -label "File" 
  1030.         -familyImage "menuIconFile.xpm"
  1031.         glFileMenu;
  1032. //        menuItem -l "Save As..." saveAsFileItem;
  1033.         menuItem -l "Close" -c ("window -e -vis 0 glRenderWindow") closeWinItem;
  1034.         setParent -menu ..;
  1035.         
  1036.     menu -p $parent 
  1037.         -label "Render" 
  1038.         -familyImage "menuIconRender.xpm"
  1039.         renderMenu;
  1040.         menuItem -l "Attributes..." -c "editRenderGlobalsRW";
  1041.         menuItem -l "Test Render" -c "glRender -renderFrame hardwareRenderView" renderFrameItem;
  1042. //        menuItem -l "Post Current Image" -c "print \"Post Current Image\\n\"" postImageItem;
  1043.         menuItem -l "Render Sequence" -c "glRender -renderSequence hardwareRenderView" renderSeqItem;
  1044.         menuItem -l "Scale Buffer" -sm true bufferScaleItem;
  1045.             radioMenuItemCollection hwBufferScaleCluster;
  1046.             for ($i = 0; $i < size($glHWrenderScales) ; $i++)
  1047.             {
  1048.                 string $label = (($glHWrenderScales[$i]*100)+" %");
  1049.                 menuItem -l $label -rb false 
  1050.                     -c ("scaleBufMenuRW "+$parent+" "+$i) ("scaleItem"+$i);
  1051.             }
  1052.             menuItem -e -rb true scaleItem0;
  1053.             setParent -menu ..;
  1054.         menuItem -l "Time Slider" -checkBox on -c ("displayTimelineRW " +$parent+ " #1") timelineItem;
  1055.         setParent -menu ..;
  1056.         
  1057.     menu -p $parent 
  1058.         -label "Cameras" 
  1059.         -pmc ("updateCameraMenuRW "+$parent) 
  1060.         -familyImage "menuIconView.xpm"
  1061.         cameraMenu;
  1062.         radioMenuItemCollection glCameraCluster;
  1063.         menuItem -l "Camera 1" -rb false glCameraItem0;
  1064.         menuItem -l "Camera 2" -rb false glCameraItem1;
  1065.         menuItem -l "Camera 3" -rb false glCameraItem2;
  1066.         menuItem -l "Camera 4" -rb false glCameraItem3;
  1067.         setParent -menu ..;
  1068.  
  1069. //    menu -p $parent 
  1070. //        -label "Options" 
  1071. //        -familyImage "menuIconOptions.xpm"
  1072. //        optionMenu;
  1073. //        menuItem -l "Display Grid Plane" -checkBox off -c "glRender -e -grid #1" gridPlaneItem;
  1074. //        menuItem -l "Display Camera Icons" -checkBox off -c "glRender -e -cameraIcons #1" camerIconItem;
  1075. //        menuItem -l "Display Light Icons" -checkBox off -c "glRender -e -lightIcons #1" lightIconItem;
  1076. //        menuItem -l "Display Emitter Icons" -checkBox off -c "glRender -e -emitterIcons #1" emitterIconItem;
  1077. //        menuItem -l "Display Field Icons" -checkBox off -c "glRender -e -fieldIcons #1" fieldIconItem;
  1078. //        menuItem -l "Display Collision Icons" -checkBox off -c "glRender -e -collisionIcons #1" collisonIconItem;
  1079. //        menuItem -l "Display Transform Icons" -checkBox off -c "glRender -e -transformIcons #1" transformIconItem;
  1080. //        menuItem -l "Background Color..." -c ("clearClrRW "+$parent) clearClrItem;
  1081. //        setParent -menu ..;
  1082.         
  1083.     menu -p $parent 
  1084.         -label "Flipbooks" 
  1085.         -familyImage "menuIconFlipbooks.xpm"
  1086.         flipbookMenu;
  1087.  
  1088.     // Add menus from previous runs if any
  1089.     int $numCurrFlipbooks = size($glHWBufferItemLabels);
  1090.     for ($i = 0 ; $i < $numCurrFlipbooks ; $i++)
  1091.     {
  1092.         menuItem -p flipbookMenu 
  1093.             -l $glHWBufferItemLabels[$i] -c $glHWBufferItemCallbacks[$i];
  1094.     }
  1095.     flipbookOptionMenuRW();
  1096.     
  1097.         setParent -menu ..;
  1098.     //    Adds support for the Context Sensitive Help Menu.
  1099.     //
  1100.  
  1101.     doHelpMenu($parent,$parent+"|workLyt");
  1102. }
  1103.  
  1104. //  ========== createWinRW ==========
  1105. //
  1106. //  SYNOPSIS
  1107. //        Create the window and all the controls.
  1108. //
  1109.  
  1110. proc  createWinRW( string $win )
  1111. {
  1112.     setUITemplate -pst NONE;
  1113.  
  1114.     //    Adds support for the Context Sensitive Help Menu.
  1115.     //
  1116.     addContextHelpProc $win "buildHardwareRenderBuffContextHelpItems";
  1117.  
  1118.     // Create window and base container widgets.
  1119.     //
  1120.     if (`about -mac`)
  1121.     {    
  1122.         window 
  1123.             -title "Hardware Render Buffer"
  1124.             //-menuBar true
  1125.             -minimizeButton false 
  1126.             -maximizeButton false
  1127.             -retain 
  1128.             -sizeable false
  1129.             //-resizeToFitChildren true
  1130.               -resizeToFitChildren false
  1131.             -topLeftCorner 270 560
  1132.             $win;
  1133.     }
  1134.     else {
  1135.         window 
  1136.             -title "Hardware Render Buffer"
  1137.             -menuBar true
  1138.             -minimizeButton false 
  1139.             -maximizeButton false
  1140.             -retain 
  1141.             -sizeable false
  1142.             -resizeToFitChildren true
  1143.          // -resizeToFitChildren false
  1144.             -topLeftCorner 270 560
  1145.             $win;
  1146.     }
  1147.  
  1148.     string $parent;
  1149.     global string $glRenderMenLayout;
  1150.          
  1151.     if (`about -mac`)
  1152.     {    
  1153.         // Create the layout appropriate for Hardware Render Buffer.
  1154.         //
  1155.         formLayout renderBufferForm;
  1156.         // Create the menubar.
  1157.         //
  1158.         setParent ($win + "|renderBufferForm");        
  1159.         $glRenderMenLayout = `menuBarLayout glRenderMenLayout`;
  1160.         createMenuRW( $glRenderMenLayout );
  1161.         $parent = $glRenderMenLayout;
  1162.     }
  1163.     else {
  1164.         // Create the menubar.
  1165.         //
  1166.         setParent $win;        
  1167.         createMenuRW( $win );
  1168.         $parent = $win; 
  1169.     }
  1170.     
  1171.     formLayout -nd 100 workLyt;
  1172.     // Create the timeline.
  1173.     //
  1174.     setParent ($parent+"|workLyt");
  1175.     formLayout timeLineLyt;
  1176.     formLayout -e
  1177.         -af timeLineLyt left 0
  1178.         -af timeLineLyt right 0
  1179.         -af timeLineLyt bottom 0
  1180.         ($parent+"|workLyt");
  1181.  
  1182.         frameLayout -lv false timeFrameLyt;
  1183.         formLayout -e
  1184.             -af timeFrameLyt left 4
  1185.             -af timeFrameLyt right 4
  1186.             -af timeFrameLyt bottom 4
  1187.             timeLineLyt;
  1188.  
  1189.             formLayout timelineLyt;
  1190.                 rowLayout 
  1191.                     -numberOfColumns 7 
  1192.                     -columnWidth 1 30
  1193.                     -columnWidth 2 30
  1194.                     -columnWidth 3 30
  1195.                     -columnWidth 4 30
  1196.                     -columnWidth 5 30
  1197.                     -columnWidth 6 30
  1198.                     -columnWidth 7 30
  1199.                     playbackRow;
  1200.                 formLayout -e
  1201.                     -ap playbackRow left -90 50
  1202.                     -af playbackRow bottom 4
  1203.                     timelineLyt;
  1204.  
  1205.                     symbolButton 
  1206.                         -image "timerew.xpm"
  1207.                         -annotation "Go to start of playback range"
  1208.                         startFrameBtn;
  1209.  
  1210.                     symbolButton 
  1211.                         -image "timeend.xpm"
  1212.                         -annotation "Step back one frame"
  1213.                         stepBwdBtn;
  1214.  
  1215.                     symbolButton 
  1216.                         -image "timerev.xpm"
  1217.                         -annotation "Play backwards"
  1218.                         playBwdBtn;
  1219.  
  1220.                     symbolButton
  1221.                         -image "rvRender.xpm"
  1222.                         -annotation "Test render: Start test render"
  1223.                         testRenderBtn;
  1224.  
  1225.                     symbolButton
  1226.                         -image "timeplay.xpm"
  1227.                         -annotation "Play forward"
  1228.                         playFwdBtn;
  1229.  
  1230.                     symbolButton
  1231.                         -image "timestart.xpm"
  1232.                         -annotation "Step forward one frame"
  1233.                         stepFwdBtn;
  1234.  
  1235.                     symbolButton
  1236.                         -image "timefwd.xpm"
  1237.                         -annotation "Go to end of playback range"
  1238.                         endFrameBtn;
  1239.                 setParent ..;
  1240.  
  1241.                 floatField 
  1242.                     -w 65 
  1243.                     -pre 0 
  1244.                     -annotation "Playback Start Time: Set the start time of the playback range"
  1245.                     timeMinFld;
  1246.                 formLayout -e
  1247.                     -af timeMinFld bottom 0
  1248.                     -af timeMinFld left 2
  1249.                     timelineLyt;
  1250.  
  1251.                 floatField 
  1252.                     -w 65 
  1253.                     -pre 0 
  1254.                     -annotation "Playback End Time: Set the end time of the playback range"
  1255.                     timeMaxFld;
  1256.                 formLayout -e
  1257.                     -af timeMaxFld bottom 0
  1258.                     -af timeMaxFld right 2
  1259.                     timelineLyt;
  1260.  
  1261.                 frameLayout -lv false -bv true -cl false -cll false timeFrameLyt;
  1262.                 formLayout -e
  1263.                     -af timeFrameLyt left -2
  1264.                     -af timeFrameLyt top -2
  1265.                     -af timeFrameLyt right -2
  1266.                     -ac timeFrameLyt bottom 6 playbackRow
  1267.                     timelineLyt;
  1268.  
  1269.                     timePort 
  1270.                         -h 26 
  1271.                         //-annotation "Select the frame for the test render" 
  1272.                         timeSld;
  1273.                 setParent ..;
  1274.             setParent ..;
  1275.         setParent ..;
  1276.     setParent ..;
  1277.  
  1278.  
  1279.     // Create the OpenGL render buffer.
  1280.     //
  1281.     setParent ($parent+"|workLyt");
  1282.     formLayout viewLyt;
  1283.         frameLayout 
  1284.             -borderVisible true 
  1285.             -borderStyle "in" 
  1286.             -collapse false 
  1287.             -collapsable false 
  1288.             -labelVisible false 
  1289.             -width 646
  1290.             -height 485
  1291.             viewFrame;
  1292.  
  1293.             glRenderEditor hardwareRenderView;
  1294.  
  1295.         setParent ..;
  1296.     setParent ..;
  1297.  
  1298.     
  1299.     // Attach the shelf, timeline, and viewframe to
  1300.     // parent form and to each other as needed.
  1301.     //
  1302.     setParent ($parent+"|workLyt");
  1303.     formLayout -e
  1304.         -af timeLineLyt left    0
  1305.         -af timeLineLyt right    0
  1306.         -af timeLineLyt bottom    0
  1307.  
  1308.         -af viewLyt left        0
  1309.         -af viewLyt top            0 
  1310.         -af viewLyt right        0
  1311.         -ac viewLyt bottom        0 timeLineLyt
  1312.         ($parent+"|workLyt");
  1313.  
  1314.     if(`about -mac`)
  1315.     {
  1316.         formLayout -edit
  1317.             -af $glRenderMenLayout "top"    0
  1318.             -af $glRenderMenLayout "left"    0
  1319.             -af $glRenderMenLayout "bottom"    0
  1320.             -af $glRenderMenLayout "right"    0
  1321.             ($win+"|renderBufferForm");
  1322.     }
  1323.     setUITemplate -ppt;
  1324.  
  1325.     // Implicitely setting the width again to force a window resize/refresh for Mac.
  1326.     //Otherwise, the time slider is not getting displayed  for the first time on Jaguar
  1327.     if(`about -mac`){
  1328.         int $width = `window -q -width $win`;
  1329.         window -e -width $width $win;
  1330.     }
  1331.  
  1332. }  // createWinRW //
  1333.  
  1334.  
  1335.  
  1336. //  ========== registerRW ==========
  1337. //
  1338. //  Description:
  1339. //        Register the callbacks on the widgets.
  1340. //
  1341.  
  1342. proc  registerRW( string $win )
  1343. {
  1344.     if(`about -mac`)
  1345.     {
  1346.         setParent ($win + "|renderBufferForm" + "|glRenderMenLayout");
  1347.     }
  1348.     else {
  1349.         setParent $win;
  1350.     }
  1351.  
  1352.     // Toolbar
  1353.     //
  1354.     symbolButton -e -c "doGlRender" testRenderBtn;
  1355.  
  1356.     // Timeline
  1357.     //
  1358.     if (`isTrue "AnimationExists"` && `exists initTimeSlider`)
  1359.     {
  1360.         symbolButton -e -c ("playbackRW "+$win+" 1") startFrameBtn;
  1361.         symbolButton -e -c ("playbackRW "+$win+" 2") stepBwdBtn;
  1362.         symbolButton -e -c ("playbackRW "+$win+" 3") playBwdBtn;
  1363.         symbolButton -e -c ("playbackRW "+$win+" 4") playFwdBtn;
  1364.         symbolButton -e -c ("playbackRW "+$win+" 5") stepFwdBtn;
  1365.         symbolButton -e -c ("playbackRW "+$win+" 6") endFrameBtn;
  1366.  
  1367.         scriptJob -protected -parent $win -conditionChange playingBack ("playbackScriptJobRW "+$win);
  1368.     }
  1369.     else
  1370.     {
  1371.         symbolButton -e -enable false startFrameBtn;
  1372.         symbolButton -e -enable false stepBwdBtn;
  1373.         symbolButton -e -enable false playBwdBtn;
  1374.         symbolButton -e -enable false playFwdBtn;
  1375.         symbolButton -e -enable false stepFwdBtn;
  1376.         symbolButton -e -enable false endFrameBtn;
  1377.     }
  1378.  
  1379.     floatField -e -cc "playbackOptions -min #1; glRender -e -frameStart #1" timeMinFld;
  1380.     floatField -e -cc "playbackOptions -max #1; glRender -e -frameEnd #1" timeMaxFld;
  1381.  
  1382.  
  1383.     // Register with glRender to call flipbookRW when a render
  1384.     // sequence is finished, so a menu item will be created and
  1385.     // relevant data can be saved to allow the user to see the
  1386.     // rendered sequence with fcheck.
  1387.     //
  1388.     glRender -e -fc "flipbookRW";
  1389.  
  1390.     // Register a scriptJob for the resolution attribute changes.
  1391.     //
  1392.     string  $hwNodesAry[] = `ls -type hwRenderGlobals`;
  1393.     int        $hwNodesCnt = size( $hwNodesAry );
  1394.  
  1395.     if ($hwNodesCnt)
  1396.     {
  1397.         scriptJob -protected -parent $win -attributeChange ($hwNodesAry[0]+".resolution") ("resChangedScriptJobRW "+$win);
  1398.     }
  1399. }  // registerRW //
  1400.  
  1401.  
  1402. //  ========== updateWinRW ==========
  1403. //
  1404. //  Description:
  1405. //        Update the ui controls to match the current render
  1406. //        state. For example, set the timeline slider to the
  1407. //        current frame range.
  1408. //
  1409.  
  1410. global proc  updateWinRW( string $win )
  1411. {
  1412.  
  1413.     if(`about -mac`)
  1414.     {
  1415.         setParent ($win + "|renderBufferForm" + "|glRenderMenLayout");
  1416.     }
  1417.     else {
  1418.         setParent $win;
  1419.     }
  1420.  
  1421.     // Set frame min/max to current frame range.
  1422.     //
  1423.     int    $fs = `playbackOptions -q -min`;
  1424.     int    $fe = `playbackOptions -q -max`;
  1425.  
  1426.     glRender -e -frameStart $fs;
  1427.     glRender -e -frameEnd $fe;
  1428.  
  1429.     floatField -e -v $fs timeMinFld;
  1430.     floatField -e -v $fe timeMaxFld;
  1431. }
  1432.  
  1433.  
  1434. //  ========== glRenderWin ==========
  1435. //
  1436. //  SYNOPSIS
  1437. //        Main entry point. Must be last procedure in file.
  1438. //
  1439.  
  1440. global proc int  glRenderWin() 
  1441. {
  1442.     global string $glRenderBufferWin;
  1443.  
  1444.     string    $win = "glRenderWindow";
  1445.     if (`about -mac`)
  1446.     {
  1447.         $glRenderBufferWin = $win + "|renderBufferForm" + "|glRenderMenLayout";
  1448.     }
  1449.     else {
  1450.         $glRenderBufferWin = $win;
  1451.     }
  1452.  
  1453.     int        $firstTime = 0;
  1454.  
  1455.     if (!`licenseCheck -m "edit" -typ "complete"`) {
  1456.         warning "You are not licensed to use the Hardware Render Window.";
  1457.         return 1;
  1458.     }
  1459.  
  1460.     if (! `window -exists $win`)
  1461.     {
  1462.         createWinRW( $win );
  1463.         registerRW( $win );
  1464.     }
  1465.  
  1466.     updateWinRW( $win );
  1467.     showWindow( $win );
  1468.  
  1469.     // For now, resize the window whenever it is posted because the 
  1470.     // scriptJob fails on File->New. This call can be removed when
  1471.     // that bug is fixed (79322).
  1472.     //
  1473.     resChangedScriptJobRW( $win );
  1474.  
  1475.     if ( `about -mac` ) {
  1476.         // The timeline does not return it's true size the first time on the
  1477.         // Mac, so we need to give a second kick.  
  1478.         //
  1479.         resChangedScriptJobRW( $win );
  1480.     }
  1481.  
  1482.     return( 1 );
  1483.  
  1484. }  // glRenderWin //
  1485.